package com.lmx.repoDomain.repository;

import javax.annotation.PostConstruct;

import org.springframework.stereotype.Component;

import com.lmx.repoDomain.tmodel.Cargo;

import io.katharsis.repository.annotations.JsonApiResourceRepository;
import io.katharsis.repository.annotations.JsonApiSave;

@JsonApiResourceRepository(value = Cargo.class)
@Component
public class CargoRepository extends BaseRepository<Cargo> {

	@PostConstruct
	public void init() {
		dslJpaService.setEntityClass(Cargo.class); 
	}

	@Override
	@JsonApiSave
	public Cargo save(Cargo record) {
		if (record.getId() == null) {
			dslJpaService.create(record);
			return record;
		} else {
			if (record.getDelStatus() == 1) {// 删除
				dslJpaService.update(record);
			} else {
				dslJpaService.update(record);
			}
			return record;
		}
	}
}